package main

import (
	"dao/mapper"
	"fmt"
)

func main() {

	//fmt.Println(StringUtils.IsEmpty("        "))
	//fmt.Println(DateUtils.GetCurrDateTime())
	//fmt.Println(DateUtils.GetDateDiff("20171231","20181231"))
	//fmt.Println(DateUtils.GetDateTimeDiff("20171231120308","20171231120305"))
	//fmt.Println(DateUtils.GetCountDateTime("20171231120308",100))
	//fmt.Println(DateUtils.GetCountDate("20171231",5))
	//fmt.Println(DateUtils.GetCountMonth("201712",5))
	//fmt.Println(DateUtils.GetCountYear("2017",5))
	//fmt.Println(DateUtils.GetMonthDay(2018,4))
	//fmt.Println(DateUtils.FirstDayOfMonth("20180420"))
	//fmt.Println(DateUtils.LastDayOfMonth("20180520"))
	//fmt.Println(DateUtils.GetMonthBetween("201805","201809"))
	//fmt.Println(DateUtils.GetCurrDateHm())
	//fmt.Println(DateFormatUtils.Format("20180420152401","20060102150405","2006-01-02 15:04:05"))
	//fmt.Println(DateFormatUtils.Format("20180420152401",DateFormatUtils.DATEFORMAT_yyyyMMddHHmmss,DateFormatUtils.DATEFORMAT_yyyyMMddHHmmssC))
	//fmt.Println(FileUtils.ReadFile(`E:/HHH.scala`))

	//fmt.Println(FileUtils.CreateDirs("E:/a/b/c/d/e/f"))
	//fmt.Println(FileUtils.GetPathFromFilePath("E:/a/b/c/d/e/f/kkk.txt"))
	//fmt.Println(FileUtils.CreateMessageFile("cccccccccccccccccccccc中文ccc","E:/a/b/c/d/e/f/kkk.txt"))
	//fmt.Println(FileUtils.AppendMessageFile("cccccccccccccccccccccc中文ccc","E:/a/b/c/d/e/f/kkk.txt"))
	//fmt.Println(FileUtils.AppendMessageFile("cccccccccccccccccccccc中文ccc","E:/a/b/c/d/e/f/kkk.txt"))
	//fmt.Println(FileUtils.DeleteFile("E:/a/b/c/d/e/f/kkk.txt"))
	//
	//fmt.Println(PropertiesUtils.GetValue("E:/a/b/c/d/e/f/a.txt","default","ccc"))
	//fmt.Println(PropertiesUtils.SetValue("AAAAAAAAAAAA","default","ccc","cccValue",5))
	//fmt.Println(PropertiesUtils.GetValue("AAAAAAAAAAAA","default","ccc"))
	//time.Sleep(8000000000)
	//fmt.Println(PropertiesUtils.GetValue("AAAAAAAAAAAA","default","ccc"))

	//fmt.Println(ServerInfoUtils.GetIPByInternetName("WLAN"))
	//fmt.Println(ServerInfoUtils.GetIPByHostName())
	//fmt.Println(ServerInfoUtils.GetIP())
	//fmt.Println(ServerInfoUtils.GetHostName())
	//fmt.Println(ServerInfoUtils.GetPid())

	//fmt.Println(HttpUtils.Get("https://www.baidu.com"))
	//fmt.Println(HttpUtils.Post("https://www.baidu.com","s=123"))
	//http.HandleFunc("/",func (w http.ResponseWriter, req *http.Request) {
	//	CookieUtils.AddCookie(w,"123333333","4444444444444")
	//	io.WriteString(w, "hello world!\n")
	//})
	//
	//http.ListenAndServe(":8080", nil)

	//fmt.Println(FormatMapUtils.FormatDBNameToVarName("tbl_sys_dic"))
	//var m = make(map[string]interface{})
	//m["l1_code"]="1333333333"
	//m["l2_code"]=123333333333
	//fmt.Println(FormatMapUtils.FormatMapKey(m))

	//var m1 = make(map[string]interface{})
	//m1["l1_code"]="1333333333"
	//m1["l2_code"]=123333333333
	//var m2 = make(map[string]interface{})
	//m2["l1_code"]="1333333333"
	//m2["l2_code"]=123333333333
	//var mslice = []map[string]interface{}{m1,m2}
	//fmt.Println(FormatMapUtils.FormatMapKeyInSlice(mslice))
	//var logger = HLogger.GetHLogger("kkk")
	//logger.Appenders[2].ParseLayout(HLogger.TxnContext{1,nil},"[%T][%P][%i{14}][%d{yyyyMMdd HHmmss,SSS}][%f{25}] %m%n")
	//var m = make(map[string]string)
	//m["loglevel"]="INFO"
	//var s =logger.Appenders[2].ParseLayout(HLogger.TxnContext{1,m},"aaaaaaaaaaaaaaa")
	//logger.Info("1111111111")
	//logger.Info("2222222222")
	//logger.Info("3333333333333333")

	//var m = make(map[string]string)
	//m["loglevel"]="INFO"
	//var txnContext = HLogger.TxnContext{Txnid:"00001"}
	//logger.InfoWithTxnContext(txnContext,"1234","1233333333333")
	//exc()
	//fmt.Println(IDGeneratorTools.CreateMask(0,63))

	//var d,_= IDGeneratorTools.CreateSimpleUint64()
	//fmt.Println(d)
	//var tm,_ = IDGeneratorTools.GetDateTimeFromLong(d)
	//fmt.Println(tm)
	//d,_= IDGeneratorTools.CreateStandardLong(1,1,1,1,1)
	//fmt.Println(d)
	//var list = IDGeneratorTools.ParseStandardLong(d)
	//fmt.Println(list)
	//SNHttpServer.Run()

	//gdbc.Access()

	//var t = TblSysDic_01{}
	//t.Id=5556
	//t.L1_code ="5557"
	//t.L1_desc ="5558"
	//t.L2_code ="5559"
	//t.L2_desc ="5560"
	//t.Code_param ="5561"
	//t.Code_value ="5562"
	//t.Code_idx =5563
	//t.Live_count =5564
	//t.Create_time ="20180421185100"
	//t.Up_time  ="20180421185100"
	//it := (interface{}(t))
	//switch  v := (interface{}(t)).(type) {
	//default:
	//	fmt.Println(v)
	//}
	//fmt.Println(reflect.TypeOf(it).Kind())
	//var a int
	//var b,e = strconv.ParseInt(fmt.Sprintf("%p", unsafe.Pointer(&a))[2:],16,0)
	//if e != nil {
	//	panic(e)
	//}
	//
	//fmt.Println(fmt.Sprintf("%p", unsafe.Pointer(&a)),"       ",b)

	//
	//TestInsertOne()
	//
	//TestSelectByPk()
	////
	//TestUpdateByPk()
	////
	//TestSelectOne()
	//
	//TestSelectList()

	//var reg = regexp.MustCompile(`\$\{[A-Za-z]+[0-9A-Za-z_\ ]*\}`)
	//var strs = reg.FindAllString("select * from tbl_sys_dic where id = ${id} and l1_code = ${l1_code}",-1)
	////var strs = reg.FindStringSubmatch("select * from tbl_sys_dic where id = ${id} and l1_code = ${l1_code}")
	////var strs = reg.FindAllStringSubmatch("select * from tbl_sys_dic where id = ${id} and l1_code = ${l1_code}",-1)
	//fmt.Println(strs)
	//TestQueryOneMap()


	//var filecontent, err = FileUtils.ReadFile("D:/computer/go_workspace_sn/gdbc/TblSysDicMapper.xml")
	//if (err != nil) {
	//	panic(err)
	//}
	//var result = XmlUtils.Result{}
	//if parseResult,err := XmlUtils.Parse(filecontent,&result);!parseResult{
	//	panic(err)
	//}
	//fmt.Println("OK")
	//fmt.Println(XmlUtils.GetContentFromToken(&result.Root))
}

//func exc(){
//	var logger = HLogger.GetHLogger("kkk")
//	logger.Info("dddddd")
//}

func TestInsertOne() {
	type TblSysDic_01 struct {
		Id          int
		L1_code     string
		L1_desc     string
		L2_code     string
		L2_desc     string
		Code_param  string
		Code_value  string
		Code_idx    int
		Live_count  int
		Create_time string
		Up_time     string
	}
	var t = TblSysDic_01{
		Id:          5556,
		L1_code:     "5557",
		L1_desc:     "5558",
		L2_code:     "5559",
		L2_desc:     "5560",
		Code_param:  "5561",
		Code_value:  "5562",
		Code_idx:    5563,
		Live_count:  5564,
		Create_time: "20180421185100",
		Up_time:     "20180421185100",
	}
	mapper.TblSysDicMapper.InsertOne(nil,t)//SQL写法为按顺序插入....后期待改进按字段和顺序插入
}
func TestSelectByPk() {
	var stk = mapper.TblSysDicMapper.SelectByPk(nil,[]interface{}{5556})
	fmt.Println(stk)
	var sss = stk.(mapper.TblSysDic)
	fmt.Println(sss)
}
func TestUpdateByPk() {
	type TblSysDic_01 struct {
		L1_code     string
		L1_desc     string
		Id          int
	}
	var t = TblSysDic_01{
		Id:          5556,
		L1_code:     "8888",
		L1_desc:     "8888",
	}//或者使用数组也可以
	mapper.TblSysDicMapper.UpdateByPk(nil,t)//SQL写法为按顺序插入....后期待改进按字段和顺序插入
}
func TestDeleteByPk() {
	type TblSysDic_01 struct {
		Id          int
	}
	var t = TblSysDic_01{
		Id:          5556,
	}//或者使用数组也可以
	mapper.TblSysDicMapper.DeleteByPk(nil,t)//SQL写法为按顺序插入....后期待改进按字段和顺序插入
}
func TestSelectOne() {
	//参数可以用：结构体或者数组，结构体按照结构体定义的顺序转化为数组，最终的替换字符为数组顺序
	var result = mapper.TblSysDicMapper.SelectOne(nil,[]interface{}{5556})
	fmt.Println(result)
}
func TestSelectList() {
	//参数可以用：结构体或者数组，结构体按照结构体定义的顺序转化为数组，最终的替换字符为数组顺序
	var result = mapper.TblSysDicMapper.SelectList(nil,nil)
	for _,cell := range result {
		fmt.Println(cell)
	}
}
func TestQueryOneMap() {
	//参数可以用：结构体或者数组，结构体按照结构体定义的顺序转化为数组，最终的替换字符为数组顺序
	var parammap = make(map[string]interface{})
	parammap["id"]=5556
	parammap["l1_code"]="8888"
	parammap["l2_code"]="8888"
	parammap["code_idx"]=5563
	var result = mapper.TblSysDicMapper.QueryOneMap(nil,parammap)
	fmt.Println(result)
}
